package com.bianxingji.api;

import com.bianxingji.dto.BxjStarDto;
import com.bianxingji.model.PageResult;
import com.bianxingji.model.RestResponse;
import com.bianxingji.po.BxjStar;
import com.bianxingji.service.BxjStarService;
import com.bianxingji.vo.BxjStarVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.Map;

/**
 * @author: 24478
 * @create: 2024-12-09 11:56
 **/
@Api(tags = "名人接口")
@RestController
@RequestMapping("/star")
public class BxjStarController {

    @Autowired
    private BxjStarService bxjStarService;

    @ApiOperation("随机获取信息")
    @PostMapping("/getRandomStarList")
    public RestResponse<PageResult<BxjStar>> getCommentList(){
        return  RestResponse.success(bxjStarService.getRandomStarList());
    }

    @ApiOperation("获取分页信息")
    @PostMapping("/page")
    public RestResponse<PageResult<BxjStarVo>> getPage(@RequestBody Map<String,Object> map){
        return  RestResponse.success(bxjStarService.getPage(map));
    }

    @ApiOperation("修改状态")
    @GetMapping("/updateStatus")
    public RestResponse updateStatus(Integer id, Integer status){
        return  RestResponse.success(bxjStarService.updateStatus(id,status));
    }

    @ApiOperation("修改或者新增")
    @PostMapping("/saveOrUpdate")
    public RestResponse saveOrUpdateStar(@RequestBody BxjStarDto bxjStarDto){
        return  RestResponse.success(bxjStarService.saveOrUpdateStar(bxjStarDto));
    }

    @ApiOperation("删除")
    @DeleteMapping("/delete")
    public RestResponse deleteStar(@RequestBody BxjStarDto bxjStarDto){
        return  RestResponse.success(bxjStarService.deleteStar(bxjStarDto));
    }

    @ApiOperation("批量删除")
    @DeleteMapping("/deleteBatch")
    public RestResponse deleteBatch(@RequestBody String [] ids){
        return  RestResponse.success(bxjStarService.deleteBatch(ids));
    }

    @ApiOperation("上传头像")
    @PostMapping("/uploadAvatar")
    public RestResponse uploadAvatar(@RequestBody BxjStar bxjStar) throws IOException {
        return  RestResponse.success(bxjStarService.uploadAvatar(bxjStar));
    }

}
